package com.lx.spring.config.config;

import com.lx.spring.book.dao.BookDAO;
import com.lx.spring.config.bean.Car;
import com.lx.spring.config.bean.Color;
import org.springframework.context.annotation.*;

@Configuration
@ComponentScan(value = {"com.lx.spring.book.*.*", "com.lx.spring.book.*","com.lx.spring.config.bean"})
public class QualifierConfig {

    @Primary
    @Bean(name="bookDAO2")
    public BookDAO bookDAO(){
        BookDAO bookDAO = new BookDAO();
        bookDAO.setLabel("2");
        return bookDAO;
    }

    // 这里参数注入等同于在参数上添加 @Autowired 注解, 只是Bean注解管理参数注入会被自动管理,可以声明 @Autowired
    // 且只有一个有参构造器时,也可以实现自动注入
    @Bean
    public Car car(Color color){
        System.out.println(color);
        return new Car(color);
    }



}
